<template>
  <div class="home-container">
    <el-card>
      <div class="quick-actions">
        <el-button type="primary" @click="goVerify">身份验证</el-button>
      </div>
    </el-card>
  </div>
</template>
<script setup>
import { ref ,onMounted} from 'vue'
import { useRouter } from 'vue-router'
import axios from 'axios'
import { ElMessage } from 'element-plus'
import { UploadFilled } from '@element-plus/icons-vue'

const router = useRouter()

const mes = ref('')
const ws=ref()
const connect = () => {
  ws.value = new WebSocket('ws://127.0.0.1:8888/ws/123')

  
  ws.value.onopen = () => {
    console.log('连接成功');
  }

  ws.value.onmessage = (event) => {
    console.log("收到消息")
    console.log("收到消息：", event.data);
  }

  ws.value.onerror = (err) => {
    console.log(err)
}

    ws.value.onclose = () => {
    console.log('连接已关闭');
    }
}

const goVerify = () => {
  router.push('/idcard-verify')
}
// const afterIDCardRead= async(fileInfo)=>{
//   const formData = new FormData();
//   formData.append("file", fileInfo.file);
//   formData.append("token", token.value);
//   try {
//     const res = await axios.post("https://upload-z2.qiniup.com", formData);
//     console.log(res);
    
//     const img_url = "http://t4vxr8qpc.hn-bkt.clouddn.com/" + res.data.key;
//     const res1 = await axios.get("http://127.0.0.1:8888/idcard/redis1",{params:{url:img_url}});
//     console.log(res1);
//   } catch (error) {
//     console.error("上传失败:", error.response?.data || error.message);
//   }
// }

onMounted(() => {
  connect()
})
</script>

<style scoped>
.home-container { max-width: 800px; margin: 40px auto; }
.quick-actions { display: flex; gap: 12px; }
</style>